<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Menu extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('menu',['comment'=>'菜单信息']);
        $table->addColumn('title','string',['limit'=>50,'default'=>'','comment'=>'菜单名'])
            ->addColumn('fid','integer',['limit'=>11,'default'=>0,'comment'=>'父级菜单ID'])
            ->addColumn('url','string',['limit'=>50,'default'=>'','comment'=>'链接'])
            ->addColumn('auth','integer',['limit'=>11,'default'=>0,'comment'=>'访客权限'])
            ->addColumn('sort','integer',['limit'=>11,'default'=>0,'comment'=>'排序'])
            ->addColumn('show','integer',['limit'=>11,'default'=>1,'comment'=>'是否显示 1-显示 0-隐藏'])
            ->addColumn('icon','string',['limit'=>50,'default'=>'','comment'=>'图标'])
            ->addColumn('level','integer',['limit'=>11,'default'=>1,'comment'=>'菜单层级：1-一级菜单 2-二级菜单，3-按钮'])
            ->addColumn('component','string',['limit'=>255,'default'=>'','comment'=>'前端组件'])
            ->addColumn('router','string',['limit'=>255,'default'=>'','comment'=>'前端路由'])
            ->create();
    }
}
